package com.bang.study.buildConfig;

/**
 * @ClassName: Description
 * @Desc: TODO
 * @author: <Bang>
 * @Date: 2021/11/03 10:34
 * @Version: 1.0
 * @Modified By:
 */

import java.util.ArrayList;
import java.util.List;

/**
 * Description for {@link ConfigOption}. Allows providing multiple
 * rich formats.
 */
public class Description {

    private final List<String> blocks;

    public static DescriptionBuilder builder() {
        return new DescriptionBuilder();
    }

    public List<String> getBlocks() {
        return blocks;
    }

    /**
     * Builder for {@link Description}. Allows adding a rich formatting like lists, links,
     * linebreaks etc. For example:
     *
     * <pre>{@code
     * Description description = Description.builder()
     * 	.text("This is some list: ")
     * 	.list(
     * 		text("this is first element of list"),
     * 		text("this is second element of list with a %s", link("https://link")))
     * 	.build();
     * }</pre>
     */
    public static class DescriptionBuilder {

        private final List<String> blocks = new ArrayList<>();


        /**
         * Block of description add.
         *
         * @param block block of description to add
         * @return block of description
         */
        public DescriptionBuilder text(String block) {
            blocks.add(block);
            return this;
        }


        /** Creates description representation. */
        public Description build() {
            return new Description(blocks);
        }
    }

    private Description(List<String> blocks) {
        this.blocks = blocks;
    }
}
